#!/bin/sh

#
# Test out quiet operation on a firmware write
#

. "$(cd "$(dirname "$0")" && pwd)/common.sh"

cat >$CONFIG <<EOF
file-resource 1.bin {
	host-path = "${TESTFILE_1K}"
}
file-resource 2.bin {
	host-path = "${TESTFILE_1K}"
}
file-resource 3.bin {
	host-path = "${TESTFILE_1K}"
}
file-resource 4.bin {
	host-path = "${TESTFILE_1K}"
}

task complete {
	on-resource 1.bin { raw_write(0) }
	on-resource 2.bin { raw_write(0) }
	on-resource 3.bin { raw_write(0) }
	on-resource 4.bin { raw_write(0) }
}
EOF

$FWUP_CREATE -c -f $CONFIG -o $FWFILE

$FWUP_APPLY -q -a -d $IMGFILE -i $FWFILE -t complete > $WORK/actual_output.txt

# No output if there's quiet
cat >$WORK/expected_output.txt <<EOF
EOF
diff $WORK/expected_output.txt $WORK/actual_output.txt

# Check that the verify logic works on this file
$FWUP_VERIFY -V -i $FWFILE
